
import { prop, getModelForClass } from '@typegoose/typegoose';
enum Gender {
    MALE = 'male',
    FEMALE = 'female'
}
enum Roles {
    BigAdmin = '0',
    Admin = "1",
    Common = '2',
}


enum Constellations {
    A = '摩羯座',
    B = '水瓶座',
    C = '双鱼座',
    D = '白羊座',
    E = '金牛座',
    F = '双子座',
    G = '巨蟹座',
    H = '狮子座',
    I = '处女座',
    J = '天秤座',
    K = '天蝎座',
    L = '射手座'
}
export class User {
    @prop({
        unique: true,
        required: true,
        type: String,
        validate: {
            validator: (v) => {
                return v.length <= 7;
            },
            message: '用户名超过最大长度'
        }
    })
    username

    @prop({ required: true, type: String })
    password

    @prop({ enum: Gender, default: "male", type: String })
    sex: Gender

    @prop({ default: "人生如常", type: String, maxlength: 40 })
    description

    @prop({ default: "/delicious/tx1.jpg", type: String })
    avatar

    @prop({ required: true, default: "1970-01-01" })
    brithday

    @prop({ enum: Constellations, default: "巨蟹座" })
    constellation: Constellations

    @prop({ required: true, type: String, unique: true })
    qqnumber
    @prop({ enum: Roles, type: String, required: true, default: "2" })
    role: Roles

    @prop({ default: "", type: String })
    bilibili
}


export const UserModel = getModelForClass(User, {
    //为模型取名,默认为类的名字+s
    schemaOptions: { collection: 'user' },
})